package net.borlis.sample.services.facade.ws.response;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

/**
 * @author alex@borlis.net on 02.06.2014.
 */
@XmlRootElement
public class VitoResponse extends BaseVitoResponse {

    @XmlElement
    private String kid;

    @XmlElement
    private Integer hotelProvidersNumber;

    @XmlElement
    private Integer flightProvidersNumber;

    @XmlElement
    private CountryResponse country;

    public VitoResponse() {
        super();
    }

    public VitoResponse(Long id, String code, String name, String kid, Integer hotelProvidersNumber,
                        Integer flightProvidersNumber, CountryResponse country) {
        super(id, code, name);
        this.kid = kid;
        this.hotelProvidersNumber = hotelProvidersNumber;
        this.flightProvidersNumber = flightProvidersNumber;
        this.country = country;
    }

    public String getKid() {
        return kid;
    }

    public CountryResponse getCountry() {
        return country;
    }

    public Integer getHotelProvidersNumber() {
        return hotelProvidersNumber;
    }

    public Integer getFlightProvidersNumber() {
        return flightProvidersNumber;
    }

    @Override
    public boolean equals(Object obj) {
        if (!super.equals(obj)) {
            return false;
        }
        if (obj instanceof VitoResponse) {
            VitoResponse other = (VitoResponse) obj;
            EqualsBuilder builder = new EqualsBuilder();
            builder.append(getKid(), other.getKid());
            builder.append(getCountry(), other.getCountry());
            return builder.isEquals();
        }
        return false;
    }

    @Override
    public int hashCode() {
        HashCodeBuilder builder = new HashCodeBuilder();
        builder.append(getId());
        builder.append(getCode());
        builder.append(getName());
        builder.append(getKid());
        builder.append(getCountry());
        return builder.toHashCode();
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this).
                append("id", getId()).
                append("code", getCode()).
                append("name", getName()).
                append("kid", getKid()).
                append("hotelProvidersNumber", getHotelProvidersNumber()).
                append("flightProvidersNumber", getFlightProvidersNumber()).
                append("country", getCountry()).
                toString();
    }

}
